package special;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class LeeCode_LCP_73 {
    public static void main(String[] args) {
        System.out.println(adventureCamp(new String[]{"leet->code", "leet->code->Campsite->Leet", "leet->code->leet->courier"}));
    }
    private static int adventureCamp(String[] expeditions) {
        String[] split = expeditions[0].split("->");
        Set<String> set = new HashSet<>(Arrays.asList(split));
        int max = 0;
        int index = -1;
        for (int i = 1; i < expeditions.length; i++) {
            String s = expeditions[i];
            String[] split1 = s.split("->");
            int tmp = 0;
            for (String s1 : split1) {
                if (s1.length() == 0)
                    continue;
                if (!set.contains(s1)){
                    set.add(s1);
                    tmp++;
                }
            }
            if (tmp > max){
                max = tmp;
                index = i;
            }
        }
        return index;
    }
}
